<div class="span10" style="background: #fff;margin-left: 2px;">
<table width="100%" style="margin: 0;padding: 0;" id="_content">
    <tr>
        <td class="hzbar"></td>
        <td style="padding: 10px 15px;" valign="top">
<?php echo $this->session->flashdata('_message'); ?>
<!-- Modal Form -->
<h1>Order Detail</h1>
<?php echo anchor('administrator/shop/order/cancel/'.$orders->order_id,'Cancel','class="btn"'); ?>

<div style="margin-bottom: 15px;"></div>

<?php
global $site_info;
$payment_method = array(1=>'Trực tuyến',2=>'Ngân hàng',3=>'Tại nhà');
$shipping_method = array(1=>'Phát nhanh',2=>'Phát thường',3=>'Tại Cty',4=>'60 phút');
$payment_status = array(1=>'Đã thanh toán',2=>'Tạm giữ',0=>'Chưa thanh toán');
$order_status = array(0=>'Chưa xử lý',1=>'Đang xử lý',2=>'Đang chuyển hàng',3=>'Hoàn tất',4=>'Hủy bỏ');
if(!empty($orders)){
    $order_detail = $this->_global->_unserialize($orders->order_details);
   
?>
    <table class="table table-striped table-bordered table-condensed">
    <tr>
        <td width="25%">Order Id</td>
        <td width="25%"><?php echo $orders->order_id ?></td>
        <td width="25%">User</td>
        <td width="25%"><?php echo _get_fullname($orders->user_id) ?></td>
    </tr>
    <tr>
        <td width="25%">Created at</td>
        <td width="25%"><?php echo  mdate($site_info['time_format'].' '.$site_info['date_format'],$orders->created_at) ?></td>
        <td width="25%">Shipping method</td>
        <td width="25%"><?php echo $shipping_method[$orders->shipping_method] ?></td>
    </tr>
    <tr>
        <td width="25%">Customer IP</td>
        <td width="25%"><?php echo long2ip($orders->user_ip) ?></td>
        <td width="25%">Currency</td>
        <td width="25%"><?php echo $orders->currency_code ?></td>
    </tr>
    <tr>
        <td width="25%">Payment method</td>
        <td width="25%"><b><?php echo  $payment_method[$orders->payment_method] ?></b></td>
        <td width="25%">Payment status</td>
        <td width="25%"><select name="payment_status" id="payment_status" disabled="disabled" style="width: 150px;">
            <option value="0" <?php echo $orders->payment_status==0?'selected=selectd':'' ?>><b>Chưa thanh toán</b></option>
            <option value="1"  <?php echo $orders->payment_status==1?'selected=selectd':'' ?>>Đã thanh toán</option>
            <option value="2"  <?php echo $orders->payment_status==2?'selected=selectd':'' ?>>Tạm giữ</option>
            
        </select> <a href="javascript:;" id="updatePaymentStatus">Change</a></td>
    </tr>
    <tr>
        <td width="25%">Order Name</td>
        <td width="25%"><?php echo $orders->order_fullname ?></td>
        <td width="25%">Order Address</td>
        <td width="25%"><?php echo $orders->order_address ?></td>
    </tr>
    <tr>
        <td width="25%">Order City</td>
        <td width="25%"><?php echo $orders->order_city_id ?></td>
        <td width="25%">Order Ward</td>
        <td width="25%"><?php echo $orders->order_ward_id ?></td>
    </tr>
    <tr>
        <td width="25%">Order Phone</td>
        <td width="25%"><?php echo $orders->order_telephone ?></td>
        <td width="25%">Order Email</td>
        <td width="25%"><?php echo $orders->order_email ?></td>
    </tr>
    <tr>
        <td width="25%">Order comment</td>
        <td width="25%"><?php echo $orders->order_comment ?></td>
        <td width="25%">Promotion code</td>
        <td width="25%"><?php echo $orders->promotion_code ?></td>
    </tr>
    <tr>
        <td width="25%">Shipping name</td>
        <td width="25%"><?php echo $orders->shipping_fullname ?></td>
        <td width="25%">Shipping address</td>
        <td width="25%"><?php echo $orders->shipping_address ?></td>
    </tr>
    <tr>
        <td width="25%">Shipping city</td>
        <td width="25%"><?php echo $orders->shipping_city_id ?></td>
        <td width="25%">Shipping ward</td>
        <td width="25%"><?php echo $orders->shipping_ward_id ?></td>
    </tr>
    <tr>
        <td width="25%">Shipping phone</td>
        <td width="25%"><?php echo $orders->shipping_telephone ?></td>
        <td width="25%">Shipping Email</td>
        <td width="25%"><?php echo $orders->shipping_email ?></td>
    </tr>
    <tr>
        <td>Delivery date</td>
        <td><?php echo $orders->delivery_date ?></td>
        <td>Status</td>
        <td><select name="status" id="status" disabled="disabled" style="width: 150px;">
            <option value="0" <?php echo $orders->status==0?'selected=selectd':'' ?>>Chưa xử lý</option>
            <option value="1" <?php echo $orders->status==1?'selected=selectd':'' ?>>Đang xử lý</option>
            <option value="2" <?php echo $orders->status==2?'selected=selectd':'' ?>>Đang chuyển hàng</option>
            <option value="3" <?php echo $orders->status==3?'selected=selectd':'' ?>>Hoàn tất</option>
            <option value="4" <?php echo $orders->status==4?'selected=selectd':'' ?>>Hủy đơn hàng</option>
        </select> <a href="javascript:;" id="updateOrderStatus">Change</a></td>
    </tr>
        </table>
    <table  class="table table-striped table-bordered table-condensed">
        <tr>
        <td colspan="4"><h3>Order Detail</h3></td>
    </tr>
    <tr>
       <th>#</th>
       <th>Product name</th>
       <th>Qty</th>
       <th>Options</th>
       <th>Images</th>
       <th>Sub Total(<?php echo $orders->currency_code ?>)</th> 
    </tr>
    <?php 
        if(!empty($order_detail)){
            $total=0;
            foreach($order_detail as $dt){
                $total +=$dt['subtotal']; 
    ?>
    <tr>
        <td><?php echo $dt['id'] ?></td>
        <td><?php echo anchor($dt['options']['link'],$dt['name']) ?></td>
        <td><?php echo $dt['qty'] ?></td>
        <td><?php echo 'Size :'. $dt['options']['Size'].' Color:'.$dt['options']['Color'] ?></td>
        <td><img src="<?php echo $this->config->item('cdn_url').'exec/timthumb.php?src='.base_url()._get_image_product($dt['id'],$dt['options']['Color']).'&w=150' ?>"/></td>
        <td><?php echo $dt['subtotal'] ?></td>
    </tr>
    <?php
            }
        }
    ?>
    <tr>
        <td colspan="6" style="text-align: right;"><h3>Total:<b><?php echo $total.' '.$orders->currency_code ; ?></b></h3></td>
    </tr>
    </table>
<?php
}else{
    echo '<div class="alert alert-info"><h4 class="alert-heading">Thông báo!</h4>Chưa có đơn hàng nào...</div>';
}
?></td></tr></table>
</div>